package com.example.jdshopdeail.adapter;

import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.jdshopdeail.R;
import com.example.jdshopdeail.bean.CommentListBean;
import com.example.jdshopdeail.util.DateUtils;
import com.example.jdshopdeail.util.GlideUtils;
import com.example.jdshopdeail.util.ParseUtils;

import java.util.List;

/**
 * @author: njb
 * @date:   2020/3/24 0024 19:46
 * @desc:   商品评论列表
 */
public class CommentListAdapter extends BaseQuickAdapter<CommentListBean, BaseViewHolder> {
    private TextView textView;
    private String goods_name;
    private TextView addressTv;

    public CommentListAdapter(@Nullable List<CommentListBean> data) {
        super(R.layout.item_shop_evaluation, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, CommentListBean item) {
        if (item == null) {
            return;
        }
        Drawable drawable = ContextCompat.getDrawable(mContext, R.mipmap.location);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        textView = helper.getView(R.id.product_name_tv);
        addressTv = helper.getView(R.id.address_tv);
        helper.setText(R.id.user_name_tv, item.getUser_name());
        helper.setText(R.id.time_tv, "2020-03-06");
        textView.setText(goods_name);
        helper.setText(R.id.evaluation_content_tv, item.getContent());
/*        if (item.getImg() != null && item.getImg().size() > 0) {
            helper.getView(R.id.ll_evaluation).setVisibility(View.VISIBLE);
            if (item.getImg().size() == 1) {
                GlideUtils.loadImg(mContext, item.getImg().get(0),
                        (ImageView) helper.getView(R.id.goods_iv_one), R.mipmap.default_comment);
            } else if (item.getImg().size() == 2) {
                GlideUtils.loadImg(mContext, item.getImg().get(0),
                        (ImageView) helper.getView(R.id.goods_iv_one), R.mipmap.default_comment);
                GlideUtils.loadImg(mContext, item.getImg().get(1),
                        (ImageView) helper.getView(R.id.goods_iv_two), R.mipmap.default_comment);
            } else if (item.getImg().size() == 3) {
                GlideUtils.loadImg(mContext, item.getImg().get(0),
                        (ImageView) helper.getView(R.id.goods_iv_one), R.mipmap.default_comment);
                GlideUtils.loadImg(mContext, item.getImg().get(1),
                        (ImageView) helper.getView(R.id.goods_iv_two), R.mipmap.default_comment);
                GlideUtils.loadImg(mContext, item.getImg().get(2),
                        (ImageView) helper.getView(R.id.goods_iv_three), R.mipmap.default_comment);
            }
        } else {
            helper.getView(R.id.ll_evaluation).setVisibility(View.GONE);
        }*/
        helper.addOnClickListener(R.id.goods_iv_one);
        helper.addOnClickListener(R.id.goods_iv_two);
        helper.addOnClickListener(R.id.goods_iv_three);
    }


    public void setGoods_name(String goods_name) {
        if (goods_name != null) {
            this.goods_name = goods_name;
        }
    }
}
